package com.zking.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zking.ssm.mapper.HotelSellerMapper;
import com.zking.ssm.model.HotelSeller;
import com.zking.ssm.service.IHotelSellerService;
import com.zking.ssm.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class HotelSellerServiceImpl implements IHotelSellerService {

    @Autowired
    private HotelSellerMapper hotelSellerMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return hotelSellerMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(HotelSeller record) {
        return hotelSellerMapper.insert(record);
    }

    @Override
    public int insertSelective(HotelSeller record) {
        return hotelSellerMapper.insertSelective(record);
    }

    @Override
    public HotelSeller selectByPrimaryKey(Integer id) {
        return hotelSellerMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(HotelSeller record) {
        return hotelSellerMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(HotelSeller record) {
        return hotelSellerMapper.updateByPrimaryKeyWithBLOBs(record);
    }

    @Override
    public int updateByPrimaryKey(HotelSeller record) {
        return hotelSellerMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<HotelSeller> selectAll(HotelSeller hotelSeller, PageBean pageBean) {
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageHelper.startPage(pageBean.getPage(), pageBean.getRows());
        }
        List<HotelSeller> hotelSellerList = hotelSellerMapper.selectAll(hotelSeller);
        if (null != pageBean && 0 != pageBean.getRows()) {
            PageInfo pageInfo = new PageInfo(hotelSellerList);
            pageBean.setTotal(pageInfo.getTotal() + "");
        }
        return hotelSellerList;
    }
}
